
#!/bin/bash

packagename=`find . -maxdepth 1 -name "*.jar"`
function status(){
   pid=$(ps -ef | grep $packagename | grep -v grep | awk '{print $2}')
   if [ $pid ];then
       echo running
   else
       echo stoped
   fi
}

function stop() {
   pid=$(ps -ef | grep $packagename | grep -v grep | awk '{print $2}')
   if [ $pid ];then
     kill -9 $pid
   fi
}

function start() {
   nohup java -Xms128m -Xmx256m -jar -Dloader.path=libs $packagename > /dev/null 2>&1 &
}

case $1 in
stop)
   stop
   ;;
start)
   start
   ;;
status)
   status
   ;;
restart)
   stop
   start
   ;;
*)
   echo "请输入正确的参数：如：stop,start,status,restart"
   ;;
esac
